package exam.ant.S2;

import java.util.*;

public class Main {

    public static int n;
    public static List<Integer>[] tree;
    public static int[] vals;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        tree = new List[n + 1];
        vals = new int[n + 1];
        Arrays.fill(vals, 1);
        int u = 0, v = 0;
        for (int i = 0; i < n - 1; i++) {
            u = sc.nextInt();
            v = sc.nextInt();
            if (u > v) {
                int t = u;
                u = v;
                v = t;
            }
            if (tree[u] == null)
                tree[u] = new ArrayList<>();
            tree[u].add(v);
        }
        System.out.println(tranverse(1, 0));
    }

    private static long tranverse(int root, long sum) {
        vals[root] += sum;
        long res = vals[root] > root ? 0L : root - vals[root];
        sum += res;
        if (tree[root] == null)
            return res;
        for (int i = 0; i < tree[root].size(); i++)
            res += tranverse(tree[root].get(i), sum);
        return res;
    }
}